package com.example.controller;

import com.example.entity.Subject;
import com.example.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/subject")
public class SubjectController {

    @Autowired
    SubjectService subjectService;

    @GetMapping("/all")
    public Object getAll(){
        return subjectService.getAll();
    }

    @GetMapping("/one/{id}")
    public Object getOne(@PathVariable Integer id){
        return subjectService.getOne(id);
    }

    @PutMapping("/update")
    public Object update(@RequestBody Subject subject){
        subjectService.update(subject);
        return subjectService.getOne(subject.getSubjectNo());
    }
}
